#include "../inc/plan.h"
#include <math.h>

Plan::Plan()
{
	a = 0;
	b = 0;
	c = 0;
	d = 0;
}

Plan::Plan(Vector3D _p, Vector3D _v)
{
	a = _v.getX();
	b = _v.getY();
	c = _v.getZ();
	d = -( (a*_p.getX()) + (b*_p.getY()) + (c*_p.getZ()) );
}

Plan::Plan( const Plan& _p )
{
	a = _p.a;
	b = _p.b;
	c = _p.c;
	d = _p.d;
}

Plan::~Plan()
{
	
}

Plan& Plan::operator = (const Plan& _p)
{
	a = _p.a;
	b = _p.b;
	c = _p.c;
	d = _p.d;
	
	return *this;
}


double Plan::getA()
{
	return a;
}

double Plan::getB()
{
	return b;
}

double Plan::getC()
{
	return c;
}

double Plan::getD()
{
	return d;
}

void Plan::setA(double _a)
{
	a = _a;
}

void Plan::setB(double _b)
{
	b = _b;
}

void Plan::setC(double _c)
{
	c = _c;
}

void Plan::setD(double _d)
{
	d = _d;
}

double Plan::distance(Vector3D _p)
{
	double tmp1 = fabs ( (a*_p.getX()) + (b*_p.getY()) + (c*_p.getZ()) + d );
	double tmp2 = sqrt( (a*a) + (b*b) + (c*c) );
	
	return ( tmp1/tmp2 );
}

double Plan::signedDistance(Vector3D _p)
{
	double tmp1 = (a*_p.getX()) + (b*_p.getY()) + (c*_p.getZ()) + d;
	double tmp2 = sqrt( (a*a) + (b*b) + (c*c) );
	
	return ( tmp1/tmp2 );
}
